<include file="Common:layout" />
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>添加管理员</h3>
                <h5>添加后台管理员</h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" id="handleposition" action="{:U('Auth/add_administrators')}" method="post">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label>所在组</label>
                </dt>
                <dd class="opt">
                    <select name="role_id" class="roleId">
                        <option value="">-- 请选择 --</option>
                        <foreach name="roleList" item="role">
                            <option value="{$role['role_id']}">{$role['name']}</option>
                        </foreach>
                    </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>姓名</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="name" id="c_name" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请填写管理员姓名</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>手机</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="mobile" id="mobile" class="input-txt" maxlength="11" data-type="number"/>
                    <span class="err"></span>
                    <p class="notic">请填写管理员手机号</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>邮箱</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="email" id="email" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请填写管理员邮箱</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>密码</label>
                </dt>
                <dd class="opt">
                    <input type="password" name="pwd" id="pwd" class="input-txt">
                    <span class="err"></span>
                    <p class="notic">请填写管理员登录密码</p>
                </dd>
            </dl>
            <div class="bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $('#submitBtn').click(function () {
            var c_name = $('#c_name').val();
            var mobile = $('#mobile').val();
            var email = $('#email').val();
            var roleId = $('.roleId').val();
            var pwd = $('#pwd').val();
            if (roleId == '') {
                layer.alert('角色必选！');
                return false;
            }
            if (c_name == '') {
                layer.alert('姓名必填！');
                return false;
            }
            var mobilePattern = /^0?1[3|4|5|7|8][0-9]\d{8}$/;
            if (!mobilePattern.test(mobile)) {
                layer.alert('手机号码有误！');
                return false;
            }
            if (email == '') {
                layer.alert('邮箱必填！');
                return false;
            }
            if (pwd == '') {
                layer.alert('密码必填！');
                return false;
            }
            $("#handleposition").submit();
        });
    });
</script>
</body>
</html>